package com.antler.smt.portal.controller;

import com.antler.smt.response.admin.GetUserListResp;
import com.antler.smt.response.base.Result;
import com.antler.smt.service.portal.ShowUserService;
import com.antler.smt.utils.LogUtil;
import com.antler.smt.validate.DataValidator;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 根据需求获取当前订单下的匹配的项目专员的信息
 *
 * @author zhangyi
 * @date 2018/4/27 10:20
 */
@RestController
@RequestMapping("/showUser")
@Api(description = "根据需求获取当前订单下的匹配的项目专员的信息")
public class ShowUserController {

    /**
     * 日志
     */
    private static Logger log = LogUtil.get();

    @Resource
    private ShowUserService showUserService;

    /**
     * 显示项目专员
     *
     * @param requirementId 获取此时发布需求的id
     * @return
     */
    @GetMapping("/getUser")
    @ApiOperation(value = "显示项目专员", httpMethod = "GET")
    public Result<GetUserListResp> userInfo(@RequestParam(value = "requirementId") long requirementId){

        DataValidator.isBlank(String.valueOf(requirementId),"需求id不能为空！");

        Result result = null;
            result = showUserService.getUserInfoByRequirementId(requirementId);
        return result;
    }

    /**
     * 显示商务专员
     *
     * @param requirementId 获取此时发布需求的id
     * @return
     */
    @GetMapping("/businessUserInfo")
    @ApiOperation(value = "显示商务专员", httpMethod = "GET")
    public Result<GetUserListResp> businessUserInfo(@RequestParam(value = "requirementId") long requirementId){

        DataValidator.isBlank(String.valueOf(requirementId),"需求id不能为空！");

        Result result = null;
            result = showUserService.getBusinessUserInfoByRequirementId(requirementId);
        return result;
    }
}
